package com.jdk8datedemo;

import java.time.LocalDate;
import java.time.Period;

public class PeriodDemo {
    public static void main(String[] args) {
        //当前本地年月日
        LocalDate now = LocalDate.now();
        System.out.println(now);

        //生日的年月日
        LocalDate birthday = LocalDate.of(2000, 1, 1);
        System.out.println(birthday);

        //第二个参数减第一个参数
        Period period = Period.between(birthday, now);
        System.out.println(period);
        System.out.println(period.getYears());
        System.out.println(period.getMonths());
        System.out.println(period.getDays());

        System.out.println(period.toTotalMonths());

    }
}
